import {
    isNotInclude3and5and7,
    isInclude3Only,
    isInclude5Only,
    isInclude7Only,
    isInclude3and5Only,
    isInclude3and7Only,
    isInclude5and7Only,
    isInclude3and5and7
} from './methods/whetherIncudeMethod'
import {
    is3Multiple,
    is5Multiple,
    is7Multiple
} from './methods/whetherMultipleMethod'
import { RESULT }  from './results/fizzBuzzConverterResult'
export type FizzBuzzType = number | string;
function fizzBuzzConverter(a: number) {
    if (!is3Multiple(a) && !is5Multiple(a) && !is7Multiple(a)) { // 不是 3、5、7 的倍数
        if (
            isNotInclude3and5and7(a) ||
            isInclude5Only(a) ||
            isInclude7Only(a) ||
            isInclude3and5Only(a) ||
            isInclude5and7Only(a) ||
            isInclude3and5and7(a)
        ) {
            return a.toString()
        }else if (
            isInclude3Only(a) ||
            isInclude3and7Only(a)
        ) {
            return RESULT.Fizz
        }
    }else if (is3Multiple(a) && is5Multiple(a) && is7Multiple(a)) {// 是 3、5、7 的倍数
        if(isNotInclude3and5and7(a)) {
            return RESULT.FizzBuzzWhizz
        }else if (
            isInclude3Only(a) ||
            isInclude3and7Only(a)
        ) {
            return RESULT.Fizz
        }else if (
            isInclude5Only(a) ||
            isInclude3and5Only(a)
        ) {
            return RESULT.BuzzWhizz
        }else if (
            isInclude7Only(a) ||
            isInclude5and7Only(a) ||
            isInclude3and5and7(a)
        ) {
            return RESULT.FizzWhizz
        }
    }else if (is3Multiple(a) && is5Multiple(a)) {// 为 3、5 的倍数
        if(isNotInclude3and5and7(a)) {
            return RESULT.FizzBuzz
        }else if(
            isInclude3Only(a) ||
            isInclude7Only(a) ||
            isInclude3and7Only(a) ||
            isInclude5and7Only(a) ||
            isInclude3and5and7(a)
        ) {
            return RESULT.Fizz
        }else if(
            isInclude5Only(a) ||
            isInclude3and5Only(a)
        ) {
            return RESULT.Buzz
        }
    }else if(is3Multiple(a) && is7Multiple(a)) {// 为 3、7 的倍数
        if(
            isNotInclude3and5and7(a) ||
            isInclude7Only(a) ||
            isInclude5and7Only(a) ||
            isInclude3and5and7(a)
        ) {
            return RESULT.FizzWhizz
        }else if(
            isInclude3Only(a) ||
            isInclude3and7Only(a)
        ) {
            return RESULT.Fizz
        }else if(
            isInclude5Only(a) ||
            isInclude3and5Only(a)
        ) {
            return RESULT.Whizz
        }
    }else if(is5Multiple(a) && is7Multiple(a)) {// 为 5、7 的倍数
        if(
            isNotInclude3and5and7(a) ||
            isInclude5Only(a) ||
            isInclude3and5Only(a)
        ) {
            return RESULT.BuzzWhizz
        }else if(
            isInclude3Only(a) ||
            isInclude3and7Only(a)
        ) {
            return RESULT.Fizz
        }else if(
            isInclude7Only(a) ||
            isInclude5and7Only(a) ||
            isInclude3and5and7(a)
        ) {
            return RESULT.Whizz
        }
    }else if(is3Multiple(a)) {// 为 3 的倍数
        if(
            isInclude3Only(a) ||
            isNotInclude3and5and7(a) ||
            isInclude7Only(a) ||
            isInclude3and7Only(a) ||
            isInclude5and7Only(a) ||
            isInclude3and5and7(a)
        ) {
            return RESULT.Fizz
        }else if(
            isInclude5Only(a) ||
            isInclude3and5Only(a)
        ) {
            return a.toString()
        }
    }else if(is5Multiple(a)) {// 为 5 的倍数
        if(
            isNotInclude3and5and7(a) ||
            isInclude5Only(a) ||
            isInclude3and5Only(a)
        ) {
            return RESULT.Buzz
        }else if(
            isInclude3and7Only(a) ||
            isInclude3Only(a)
        ) {
            return RESULT.Fizz
        }else if(
            isInclude5and7Only(a) ||
            isInclude3and5and7(a) ||
            isInclude7Only(a)
        ) {
            return a.toString()
        }
    }else if(is7Multiple(a)) {// 为 7 的倍数
        if(
            isNotInclude3and5and7(a) ||
            isInclude3and5Only(a) ||
            isInclude5and7Only(a) ||
            isInclude3and5and7(a) ||
            isInclude7Only(a) ||
            isInclude5Only(a)
        ) {
            return RESULT.Whizz
        }else if(
            isInclude3and7Only(a) ||
            isInclude3Only(a)
        ) {
            return RESULT.Fizz
        }
    }
    return a.toString()
}

export default fizzBuzzConverter;